#include <fstream>
#include <stdexcept>
#include <string>
#include <algorithm>

#include "big_int.h"
#include "calculator.h"

int main()
{
   std::ifstream input("in.txt");
   std::ofstream output("out.txt");

   while (input)
   {
      std::string s;
      getline(input, s);

      if (s.length() == 0)
         continue;
      try
      {
         std::pair<big_int, bool> result = calculate(s);
         output << result.first << "\n";
      }
      catch (...)
      {
         output << "<error>" << "\n";
      }

   }

   return 0;
}